#!/usr/bin/perl -w
# Copyright (C) Charles Wang 2003.
# Author: Charles Wang <charles@linux.net.cn>
use strict;

# This script is used to convert the hyperlink in the documents here in
# order to let it work in my personal site.

if (scalar(@ARGV) != 1) {
    die "Usage: to-site.pl TODIR\n";
}
my $todir = $ARGV[0];
print "todir = $todir \n";

my($html, $php, $ln);
foreach $html (glob('*.html')) {
    $php = $html;  $php =~ s/.html$/.gb2312.php/;
    print "html = $html, php = $php\n";
    open(INFD, $html) or die "Can't open $html\n";
    open(OUTFD, "> $todir/$php") or die "Can't open $todir/$php\n";
    while ($ln = <INFD>) {
	$ln =~ s@<a href="(\w+).html">@<a href="/index.php?lang=gb2312&path=compositions/MagicInstaller/docs&body=$1">@g;
	print OUTFD $ln
    }
    close(INFD);  close(OUTFD);
}
